//
//  SystemCell.swift
//  YueChat
//
//  Created by IMac on 2024/9/23.
//

import UIKit

class SystemCell: BaseChatCell {

    @IBOutlet weak var systemLab: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
//    func calculateCellHeight(message: MessageInfo, chatType: Bool, mulSelect: Bool, isMySend: Bool) {
//        message.msgCellHeight = 0
//    }
    
    override func baseCellHeight(message: DMCCMessage, chatType: Bool, mulSelect: Bool, isMySend: Bool) {
        if message.msgCellHeight > 0 {
            return
        }
        
//        if message.content != nil {
//            let content = message.content as! OsnNotifyContent
//            
//            var height = cellTextHeight(content.data, font: 16, textWith: kScreenWidth - 120)
//    //        self.cellTextHeight(message.digest(), font: 16, textWith: kScreenWidth - 120)
//            
//            if message.showTime {
//                height += 42
//            } else {
//                height += 22
//            }
//            message.msgCellHeight = Int(height)
//        }else{
//            message.msgCellHeight = Int(22)
//        }
        if message.showTime {
            message.msgCellHeight = Int(45)
        } else {
            message.msgCellHeight = Int(30)
        }
        
    }
    
    override func setMessage(_ message: DMCCMessage) {
//        super.setMessage(message)
        
        if let content = message.content as? OsnNotifyContent {
            self.systemLab.text = content.fromNotify(notify: content)
        } else {
//            self.systemLab.text = message.digest()
        }
        
//        self.systemLab.text = "123"
        // self.nickNameLabel.hidden = true  // 如果你需要这行的话，可以取消注释
        self.errorImg.isHidden = true
        self.readImg.isHidden = true
    }
    
}
